import copy

# 浅拷贝和深拷贝

# 创建一个包含嵌套列表的原始数据
original_list = [1, 2, [3, 4, 5]]

# 浅拷贝
shallow_copy = copy.copy(original_list)

# 深拷贝
deep_copy = copy.deepcopy(original_list)

# 修改嵌套列表中的元素
original_list[2][0] = 'changed'

print("原始列表:", original_list)      # [1, 2, ['changed', 4, 5]]
print("浅拷贝:", shallow_copy)         # [1, 2, ['changed', 4, 5]] - 受影响
print("深拷贝:", deep_copy)            # [1, 2, [3, 4, 5]] - 不受影响

# 修改顶层元素
original_list[0] = 'top_changed'

print("\n修改顶层元素后:")
print("原始列表:", original_list)      # ['top_changed', 2, ['changed', 4, 5]]
print("浅拷贝:", shallow_copy)         # [1, 2, ['changed', 4, 5]] - 不受影响
print("深拷贝:", deep_copy)            # [1, 2, [3, 4, 5]] - 不受影响
